/**
 *Copyright (c) 2024 watereyes
 * workflow is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.workflow.baseConfig.service.impl;

import com.koron.workflow.baseConfig.mapper.StaffMapper;
import com.koron.workflow.baseConfig.service.StaffService;
import com.koron.workflow.common.bean.PageBean;
import com.koron.workflow.common.bean.StaffBean;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author qingfeng
 * @description: TODO
 * @date 2020/4/13 10:04
 */
@Service
public class StaffServiceImpl implements StaffService {

    @Override
    @TaskAnnotation("queryByDepartmentCode")
    public List<StaffBean> queryByDepartmentCode(SessionFactory factory, String departmentCode) {
        StaffMapper mapper = factory.getMapper(StaffMapper.class);
        return mapper.queryByDepartmentCode(departmentCode);
    }


    @Override
    @TaskAnnotation("queryForList")
    public PageBean<StaffBean> queryForList(SessionFactory factory,String departmentCode, String name, Integer page, Integer pageSize) {
        StaffMapper mapper = factory.getMapper(StaffMapper.class);
        List<StaffBean> list = mapper.queryForList(departmentCode,name,page,pageSize);
        int total = mapper.countForList(departmentCode,name);
        PageBean<StaffBean> result = new PageBean<>(list,total);
        return result;
    }

    @Override
    @TaskAnnotation("queryForObject")
    public StaffBean queryForObject(SessionFactory factory, String id) {
        StaffMapper mapper = factory.getMapper(StaffMapper.class);
        return mapper.queryForObject(id);
    }

}
